﻿<?php

//////////////////////////////////////////////////////////////////////////
//
// WikiHiero2 - A PHP convert from text using "Manual for the encoding of
// hieroglyphic texts for computer input" syntax to HTML entities (table and
// images).
//
// Copyright (C) 2004-2010 Guillaume Blanchard (Aoineko)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
//////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
/**
 *
 */
class WH_Raw extends WH_Plugin
{
	protected $depth;
	protected $output;

	////////////////////////////////////////////////////////////////////////////////
	/**
	 * Constructor
	 */
	function __construct()
	{
	}

	public static function CanExport() { return true; }
	public static function CanDisplay() { return true; }
	
	public static function GetName() { return "Raw (debug)"; }
	public static function GetId() { return "Raw"; }
	public static function GetVersion() { return "0.1"; }
	public static function GetDesc($type = WH_Plugin::TypeDefault, $lang = "") { return "Raw data exporter (debug)"; }
	public static function GetCredit($lang = "") { return "Guillaume Blanchard (2004-2010)"; }
	
	////////////////////////////////////////////////////////////////////////////////
	/**
	 *
	 */
	public function &Export(&$document)
	{
		$this->depth = 0;
		$this->output = "";
		$this->ExportNode($document->GetRoot());

		return $this->output;
	}

	////////////////////////////////////////////////////////////////////////////////
	/**
	 *
	 */
	protected function ExportNode(&$node)
	{
		for($i=0; $i<$this->depth; $i++)
			$this->output .= "&nbsp;&nbsp;&nbsp;";
			//echo chr(0x09);
			
		$this->output .= "[".WH_Document::GetClassName($node->GetClass());

		foreach($node->GetAttributes() as $key => $value)
			$this->output .= " $key=\"".trim($value)."\"";

		$this->output .= "]\n";

		$this->depth++;
		foreach($node->GetChildren() as $child)
			$this->ExportNode($child);
		$this->depth--;
	}

	////////////////////////////////////////////////////////////////////////////////
	/**
	 *
	 */
 	public function Display(&$output)
	{
		echo $output;
	}
}

?>